//
//  SFSegmentControl.h
//
//  Created by 刘文 on 16/9/28.
//  Copyright © 2016年 DCloud. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "SFSegmentItem.h"

#define Default_Width           40
#define Default_Line_Height      3
#define Default_Line_Width      40
#define Default_Color           Color34
#define Default_Highlight_Color [UIColor redColor]
#define Default_Title_font      APPFONT(16)

#define Key_Title           @"title"
#define Key_Title_Detail    @"titleDetail"
#define Key_Image           @"image"

#define Item_Spacing     10

typedef NS_ENUM(NSInteger, SFSegmentType)
{
    SFSegmentTypeFilled = 0,    //  充满屏幕高度
    SFSegmentTypeFit,           //  适应文字大小
    SFSegmentTypeCircle,        //  循环
    SFSegmentTypeCustomWidth,   //自定义宽度
    SFSegmentTypeShoppingCardWidth,   //购物车宽度
};

@protocol SFSegmentControlDelegate <NSObject>

- (void)SFSegmentSelectAtIndex:(NSInteger)index animation:(BOOL)animation;

@end

@interface SFSegmentControl : UIView

@property(nonatomic, weak)      id<SFSegmentControlDelegate>    delegate;

//  选中
@property(nonatomic)            NSInteger       selectIndex;
@property(nonatomic, strong)    NSArray         *titles;

@property(nonatomic)            SFSegmentType   segmentType;
@property(nonatomic, strong)    UIImage         *backgroundImage;
@property(nonatomic)            CGFloat         lineWidth;      //  linewidth > 0，底部高亮线
@property(nonatomic, strong)    UIColor         *highlightColor;
@property(nonatomic, strong)    UIFont         *highlightTitleFont;
@property(nonatomic, strong)    UIColor         *borderColor;
@property(nonatomic)            CGFloat         borderWidth;
@property(nonatomic, strong)    UIColor         *titleColor;
@property(nonatomic, strong)    UIFont          *titleFont;

@property(nonatomic, strong, readonly)          UIScrollView        *scrollView;

- (void)load;
- (void)scrollToRate:(CGFloat)rate;

- (void)changeTitle:(NSString *)title index:(NSInteger)index;

@end
